/*
 * Copyright 2008 p.langer
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * 
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * 	http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package at.ac.tuwien.big.easyholdem.player;

import java.util.Collection;

/**
 * <p>
 * Data Access Object for persisting {@link Player}s.
 * </p> 
 *
 * <p>
 * Created on 17.01.2008 at 15:11:16.
 * </p>
 *
 * @author Philip Langer <langer[at]big[dot]tuwien[dot]ac[dot]at>
 */
public interface PlayerDAO {
	
	/**
	 * If the database is not initialized yet, this method
	 * creates the connection, creates tables.
	 */
	public void initialize();
	
	/**
	 * Returns the player with the specified <code>id</code>.
	 * 
	 * @param id id of the player.
	 * @return player with <code>id</code> or null if not existing.
	 */
	public Player getPlayerById(long id);
	
	/**
	 * Returns the player with the specified <code>userName</code>.
	 * 
	 * @param userName user name of the player.
	 * @return player with <code>userName</code> or null if not existing.
	 */
	public Player getPlayerByUsername(String userName);
	
	/**
	 * Returns all persistent players.
	 * 
	 * @return all players.
	 */
	public Collection<Player> getAll();
	
	/**
	 * Persists a newly created player. The id field will be overwritten.
	 * 
	 * @param player player to persist.
	 * @return the persisted player with the assigned id.
	 */
	public Player persist(Player player);
	
	/**
	 * Updated the specified <code>player</code>. The player must already be persistent.
	 * 
	 * @param player player to update.
	 */
	public void update(Player player);
	
	/**
	 * Deletes the specified <code>player</code>.
	 * 
	 * @param player player to delete.
	 */
	public void delete(Player player);
	
	

}
